using System;
using System.Collections.Generic;
using System.Text;

namespace RapidHDL
{
    public class TestRAM : RapidHardware
    {
        public override bool ConfigureSettings()
        {
            Settings.UseStart = false;
            Settings.BuildHardware = true;
            Settings.ForceBuildHardware = false;
            Settings.RunFromXilinx = true;
            Settings.ClockFrequency = 1;
            Settings.UseSDRAM = true;
            Settings.BuildRemote = false;
            return true;
        }

        public override bool GenerateStructure(TopLevelComponent TopLevelComponent)
        {
            TopLevelComponent.TestBusWrite.Join(0);

            NodeVector nvDataIn = new NodeVector(TopLevelComponent, "DATA_I", 4);
            NodeVector nvWriteIn = new NodeVector(TopLevelComponent, "WRITE_I", 1);
            NodeVector nvAddressIn = new NodeVector(TopLevelComponent, "ADDRESS_I", 3);
            SystemInterface.AddSignalSource("DATA_IN", nvDataIn, 0);
            SystemInterface.AddSignalSource("WRITE_IN", nvWriteIn, 0);
            SystemInterface.AddSignalSource("ADDRESS_IN", nvAddressIn, 0);

            NodeVector nvDataOut = new NodeVector(TopLevelComponent, "DATA_O", 4);

            RAM oRam = new RAM(TopLevelComponent, "ram", TopLevelComponent.MainClock, 4, 8, true);
            oRam.I_ADDRESS.Join(nvAddressIn);
            oRam.I_DATA.Join(nvDataIn);
            oRam.I_ENABLE.Join(1);
            oRam.I_WRITE.Join(nvWriteIn);

            oRam.O_DATA.Join(nvDataOut);

            return true;
        }

        public override bool ConfigureSignalViews(TopLevelComponent TopLevelComponent)
        {
            SystemInterface.AddSignalView(".DATA_O");
            return true;
        }


        public override bool GenerateHardwareScripts()
        {
            HardwareScript oScript = HardwareScripts.NewScript("test");

            return true;
        }

    }
}
